home *** CD-ROM | disk | FTP | other *** search
- Path: nrchh52.rich.nt.com!news
- From: Joseph Bell <jobell@bnr.ca>
- Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.pl1,comp.lang.apl
- Subject: Re: GOTO controversy
- Date: Tue, 19 Mar 1996 15:50:26 -0600
- Organization: Bell-Northern Research
- Message-ID: <314F2C22.3D11@bnr.ca>
- References: <rcshlds.1.000A6705@mailserv.mta.ca> <4grt4e$8fg@goanna.cs.rmit.EDU.AU> <4hl8mt$4po@newshost.cyberramp.net> <4hlg11$dd7@news1.mnsinc.com> <4hpits$1p1v@b.stat.purdue.edu> <4i0fj8$sd3@tierra.santafe.edu> <3147F456.50F0@simi.is> <4imrjm$pqm@netline-fddi.jpl.nasa.gov>
- NNTP-Posting-Host: 47.186.65.32
- Mime-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: 8bit
- X-Mailer: Mozilla 2.01 (X11; I; HP-UX A.09.05 9000/712)
-
- Sam Sirlin wrote:
- >
- > In article <3147F456.50F0@simi.is>, Bj÷rn Helgason <bjornhp@simi.is> writes:
- > |> In most instances they are not needed. I might add that in ALL cases
- > |> you could avoid GOTOs and LOOPs if you really put your mind to it.
- >
-
- At the core, all branch instructions are gotos, they are just called
- branches.
- The goto statement is admonished only when it is used to jump all around
- the
- code in "spaghetti" like manner.
-
- 10 A = 0
- 20 A = A + 1
- 30 PRINT A
- 40 IF A = 10 THEN GOTO 50 ELSE GOTO 20
- 50 PRINT "Finished"
-
- is more "cleanly" handled saying
-
- for (i = 1; i <= 10; i++)
- printf ("%d\n", i);
-
- but they are nonetheless the same when it comes to ml.
-
- but what makes more sense:
-
- if (a == 10)
- printDone();
-
- void printDone(void)
- {
- printf ("Done.\n");
- }
-
- OR
-
- 10 IF A = 10 THEN GOSUB 999
- 20
- 30
- 40
- ...
- 998 END
- 999 PRINT "DONE."
- 1000 RETURN
-
- --
- Joseph A. Bell (NOT Bret Bieghler) jobell@bnr.ca
- Northern Telecom / Bell-Northern Research
- "What? Evacuate now, in our moment of triumph? Surely you overestimate
- their chances."
-